package com.itheima.demo09;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServiceDemo03 {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10014);
        Socket accept = ss.accept();
        BufferedInputStream bis = new BufferedInputStream(accept.getInputStream());
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("day16\\a.jpg"));
        int b;
        while ((b = bis.read()) != -1) {
            bos.write(b);
        }

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bw.write("上传成功！");
        bw.newLine();
        bw.flush();

        bis.close();
        bw.close();
        ss.close();
        bos.close();
    }
}
